class PromotionsController < ApplicationController
  def index
    @promos = Promotion.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @promos }
    end
  end

  def new
    @promo = Promotion.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @fleet }
    end
  end

  def create
    @promo = Promotion.new(params[:promotion])

    if @promo.save
			respond_to do |format|
		    format.html { redirect_to(promotions_path, :notice => "La promocion #{@promo.nombre} se creo correctamente.") }
		    format.xml  { render :xml => @promo, :status => :created, :location => @promo }
			end
    else
			respond_to do |format|
		    format.html { render :action => "new" }
		    format.xml  { render :xml => @promo.errors, :status => :unprocessable_entity }
		  end
    end
  end

  def edit
    @promo = Promotion.find(params[:id])
  end

	def update
    @promo = Promotion.find(params[:id])

    if @promo.update_attributes(params[:promotion])
	    respond_to do |format|
	      format.html { redirect_to(promotions_path, :notice => 'Promotion was successfully updated.') }
	      format.xml  { head :ok }
			end
    else
	    respond_to do |format|
		    format.html { render :action => "edit" }
		    format.xml  { render :xml => @promo.errors, :status => :unprocessable_entity }
	    end
    end
  end
end
